<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<html:base />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../style.css">
<title>Administration Control Panel</title>
</head>
<body>
	<h1>Manage Posts</h1>

	<html:link action="createPost">
		<input type="button" value="Create new Post">
	</html:link>

	<table>
		<tr>
			<th><bean:message key="table.header.title"/></th>
			<th><bean:message key="table.header.showed"/></th>
			<th><bean:message key="table.header.important"/></th>
			<th><bean:message key="table.header.category"/></th>
			<th><bean:message key="table.header.createdDate"/></th>
			<th><bean:message key="table.header.modifiedDate"/></th>
			<th><bean:message key="table.header.author"/></th>
			<th><bean:message key="table.header.update"/></th>
			<th><bean:message key="table.header.delete"/></th>
		</tr>

		<logic:iterate id="post" name="postArrayList">
			<tr>
				<td width="300px"><bean:write name="post" property="title" /></td>

				<logic:equal name="post" property="showed" value="true">
					<td width="50px"><bean:message key="common.yes"/></td>
				</logic:equal>
				<logic:equal name="post" property="showed" value="false">
					<td width="90px"><bean:message key="common.no"/></td>
				</logic:equal>

				<logic:equal name="post" property="important" value="true">
					<td width="80px"><bean:message key="common.yes"/></td>
				</logic:equal>
				<logic:equal name="post" property="important" value="false">
					<td width="80px"><bean:message key="common.no"/></td>
				</logic:equal>

				<td width="200px"><bean:write name="post" property="categoryTitle" /></td>
				<td width="120px"><bean:write name="post" property="createdDate" /></td>
				<td width="130px"><bean:write name="post" property="modifiedDate" /></td>
				<td width="100px"><bean:write name="post" property="username" /></td>
				<td width="100px">
					<html:form action="updatePost.do">
						<input type="hidden" name="postId"
							value="<bean:write name="post" property="postId" />">
						<html:submit value="Update" />
					</html:form>
				</td>

				<td width="80px">
					<html:form action="deletePost.do">
						<input type="hidden" name="postId"
							value="<bean:write name="post" property="postId" />">
						<html:submit value="Delete" />
					</html:form>
				</td>

			</tr>
		</logic:iterate>
	</table>

	<html:link action="createPost">
		<input type="button" value="Create new Post">
	</html:link>

	<table>
		<tr>
			<td colspan="2">
				<logic:notEqual parameter="lastPage" value="1">
					<html:link action="posts.do" paramName="firstPage" paramId="page">First</html:link>
					<html:link action="posts.do" paramName="previousPage" paramId="page">Previous</html:link>
					<html:link action="posts.do" paramName="nextPage" paramId="page">Next</html:link>
					<html:link action="posts.do" paramName="lastPage" paramId="page">Last</html:link>
				</logic:notEqual>
			</td>
		</tr>
	</table>

</body>
</html>